# 1-4. python 2.X，3.X默认的编码格式是什么
# ASCII格式

# 1-5.将"hello_new_world"按"_"进行切割
# str1 = "hello_new_world"
# str2 = str1.split("_")
# print(str2)
# 1-6.将数字1以"0001"的格式输出到屏幕


# 2-1.字典 a = {1:1} 是否正确
#  正确

# 2-2.请合并列表 a = [1,2,3,4]和列表 b = [5,6,7,8]
# a = [1, 2, 3, 4]
# b = [5, 6, 7, 8]
# c = a + b
# print(c)

# 2-3.列表a，正序排列，倒序排列，逆序排列
# a = [2, 3, 1, 4]
# a.sort()
# print(a)   #正序
# a.sort(reverse=True)
# print(a)    #倒序
# print(a)    #逆序

# 2-4.字典 d = {"k":1,"v":2} ,请写出d.items()的结果
# d = {"k":1,"v":2}
# print(d.items())
# dict_items([('k', 1), ('v', 2)])

# 2-5.[{"k":1,"v":2},{"k":12,"v":22},{"k":13,"v":32}],请用内置方法写出按k倒序排列的代码
# str1 = [{"k": 1, "v": 2}, {"k": 12, "v": 22}, {"k": 13, "v": 32}]
# str1.sort(reverse=True)
# print(str1)

# 2-6.集合s=set([1,2,3,4]),d=set([2,4,9,0,3])，写出并集，交集
# s = set([1, 2, 3, 4])
# d = set([2, 4, 9, 0, 3])
# e = s | d
# print(e)
# f = s & d
# print(f)

# 2-7.如何把列表a=["a","b"]里的各项，转为字符串并用逗号','连接
# a = ["a", "b"]
# b = a[0]
# c = a[1]
# print(b, ",", c)

# 2-8.请随机输出大于0小于1的数，请随机输出一个100以内的整形
# import random
# a = random.random()
# print(a)
# b = random.randint(0, 100)
# print(b)

# 2-9.长度未知的元祖a=(1,3,4,5,6,...),请随机输出n个项
# import random
# a = (1, 3, 4, 5, 6, ...)
# b = random.choices(a)
# print(b)

# 2-10.代码a=[{i:j} for i,j in enumerate(xrange(5))],请写出a的最终结果
# a = [{i: j} for i, j in enumerate(xrange(5))]
# print(a)

# 2-11.分别说说函数cmp,map,filter的作用

# 3-1.
# 1.对
# 2.有序
# 3.对
# 4.a={}声明了一个空字典

# 3-2.一行代码实现求1到100的和
# i = 1
# sum1 = 0
# while i <= 100:
#     sum1 = sum1 + i
#     i += 1
# print("1~100的累积和为:%d" % sum1)

# 3-3.使用random.random方法实现随机输出范围在[25,60)中的浮点数
# import random
# a = random.uniform(25, 60)
# print(a)

# 4-2.一个list对象:a=[1,2,4,3,2,2,4],需要去掉里面的重复值
# a = [1, 2, 4, 3, 2, 2, 4]
# b = set(a)
# print(b)
# a = list(b)
# print(a)


